package escritorio.conn;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import escritorio.javaBeans.Audiencia;

public class AudienciaDao {
	private Connection conn;

	public AudienciaDao() {
		super();
		this.conn = new ConnectionFactory().getConnection();
	}

	public void insereAudiencia(Audiencia audiencia) {
		String sql = "insert into audiencia " + "(data,parecer)"
				+ " Values (?,?)";
		try {
			PreparedStatement stmt = conn.prepareStatement(sql);
			stmt.setDate(1, new Date(audiencia.getDataAudiencia()
					.getTimeInMillis()));
			stmt.setString(2, audiencia.getParecer());
			stmt.execute();
			stmt.close();
		} catch (SQLException e) {
			throw new ConnErro(null, e);
		}
	}

}
